﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;

namespace IFTRUE.FMS.Web
{
    public partial class Default : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lblUser.Text ="当前用户："+ MySession.CurrentUser.Account;

                //加载菜单
                XmlDocument doc = new XmlDocument();
                doc.Load(Server.MapPath("App_Data/menu.xml"));
                XmlNodeList list = doc.SelectNodes("//a[@role]");
                if (list != null && list.Count > 0)
                {
                    if (MySession.CurrentUser.Account != "admin")
                    {
                        foreach (XmlNode node in list)
                        {
                            if (node.Attributes["role"].Value.IndexOf(",user,")<0)
                                node.ParentNode.RemoveChild(node);
                        }
                    }
                    else
                    {
                        foreach (XmlNode node in list)
                        {
                            if (node.Attributes["role"].Value.IndexOf(",admin,")<0)
                                node.ParentNode.RemoveChild(node);
                        }
                    }
                }
                Literal1.Text = doc.OuterXml;
            }
        }
    }
}